package info.wangyuan.agent.exception;


import info.wangyuan.agent.common.Enum.MsgEnum;
import lombok.Getter;

/**
 * 业务异常类
 *
 * @author cz
 */
public class BusinessException extends RuntimeException {

    @Getter
    private int code = 400;

    private final String message;

    public BusinessException(String message) {
        this.message = message;
    }

    public BusinessException(int code, String message) {
        this(code, message, null);
    }

    public BusinessException(int code, String message, Throwable throwable) {
        super(throwable);
        this.code = code;
        this.message = message;
    }

    public BusinessException(String message, Throwable throwable) {
        super(throwable);
        this.message = message;
    }

    public BusinessException(MsgEnum msgEnum) {
        this(msgEnum.getCode(), msgEnum.getMessage(), null);
    }

    @Override
    public String getMessage() {
        return message;
    }

}
